// import * as shape from 'd3-shape';
import AbstractShape from '../base/shape';
import { ArcShapeAttribute, ArcShapeOptions } from '../declare/type';

const arcAttribute = {
  radius: 10,
  startAngle: 0,
  endAngle: Math.PI * 2,
  anticlockwise: false
};

// eslint-disable-next-line import/prefer-default-export
export class Arc extends AbstractShape {
  constructor (id: string, attribute: ArcShapeOptions = {}) {
    super(id, attribute);
    this.attribute = <ArcShapeAttribute>Object.assign(arcAttribute, this.attribute);
  }

  setRadius (radius: number = 10) {
    this.attribute.radius = radius;
    return this;
  }

  setAngle (startAngle: number = 0, endAngle: number = Math.PI * 2) {
    this.attribute.startAngle = startAngle;
    this.attribute.endAngle = endAngle;
    return this;
  }

  getAttr () : ArcShapeAttribute {
    return <ArcShapeAttribute>(this.attribute);
  }

  // eslint-disable-next-line class-methods-use-this
  draw (ctx: CanvasRenderingContext2D) {
    this.setRadius(50);
    this.setXY(50, 50);
    this.setFillStyle();
    const attr = this.getAttr();
    super.drawShape(ctx, attr, () => {
      ctx.arc(attr.x, attr.y, attr.radius, attr.startAngle, attr.endAngle, false);
    });
  }

  // eslint-disable-next-line class-methods-use-this
  assertHit (x: number, y: number): boolean {
    console.log(x, y);
    return false;
  }
}
